<?php

/**
 *  @author  Lynn Cho <lynncho@live.com>
 *  @createTime  2016-9-1 10:37:09
 *  @copyright  shewen technology
 *  @descrition  
 */
class LoginModel extends CI_Model {

    public function __construct() {
        parent::__construct();
        $this->load->library('manager/Permission');
    }

    public function verifyLogin($username, $password) {
        if (empty($username) || empty($password)) {
            return 403;
        } else {
            $password = $this->permission->customMD5($password);
            $q = $this
                    ->db
                    ->where('delete', 0)
                    ->where('username', $username)
                    ->where('pwd', $password)
                    ->limit(1)
                    ->get('manager');

            if ($q->num_rows() > 0) {
                return $q->row();
            } else {
                return 401;
            }
        }
    }

}
